package claseMetodosOrdenamiento;

import junit.framework.Assert;

import org.junit.Test;

import claseMetodosOrdenamiento.Burbujeo;
import claseMetodosOrdenamiento.Seleccion;


public class pruebaBurbujeo {

	@Test
	public void testOrdenar() {
		int[] vector = new int[]{13,15,2,1,6,0};
		
		Burbujeo ordenarConBurbuja = new Burbujeo();
		ordenarConBurbuja.ordenar(vector);
		
		Assert.assertEquals(0, vector[0]);
		Assert.assertEquals(1, vector[1]);
		Assert.assertEquals(2, vector[2]);
		Assert.assertEquals(6, vector[3]);
		Assert.assertEquals(13, vector[4]);
		Assert.assertEquals(15, vector[5]);
	}
	
	@Test
	public void testOrdenarSinCeros(){
		int[] vector = new int[]{13,15,2,1,6,20};
		
		Seleccion miSeleccion = new Seleccion();
		miSeleccion.ordenar(vector);
		
		Assert.assertEquals(1, vector[0]);
		Assert.assertEquals(2, vector[1]);
		Assert.assertEquals(6, vector[2]);
		Assert.assertEquals(13, vector[3]);
		Assert.assertEquals(15, vector[4]);
		Assert.assertEquals(20, vector[5]);
	}
	
	@Test
	public void testOrdenarVectorConValoresNegativosYPositivos(){
		int[] vector = new int[]{20, 1, -1, 0, -2};
		
		Seleccion miSeleccion = new Seleccion();
		miSeleccion.ordenar(vector);
		
		Assert.assertEquals(20, vector[4]);
		Assert.assertEquals(-2, vector[0]);
		Assert.assertEquals(-1, vector[1]);
		Assert.assertEquals(0, vector[2]);
	}

	@Test
	public void testOrdenarVectorConUnSoloValor(){
		int[] vector = new int[]{20};
		
		Seleccion miSeleccion = new Seleccion();
		miSeleccion.ordenar(vector);
		
		Assert.assertEquals(20, vector[0]);
	}
	
	@Test
	public void testOrdenarVectoresSoloConValoresNegativos(){
		
		int[] vector = new int[]{-100, -89, -5, -29, -200, -500};
		
		Burbujeo ordenarConBurbuja = new Burbujeo();
		ordenarConBurbuja.ordenar(vector);
		
		Assert.assertEquals(-500, vector[0]);
		Assert.assertEquals(-200, vector[1]);
		Assert.assertEquals(-100, vector[2]);
		Assert.assertEquals(-89, vector[3]);
		Assert.assertEquals(-29, vector[4]);
		Assert.assertEquals(-5, vector[5]);
	}
	
	@Test
	public void testOrdenarVectorVacio(){
		int[] vector = new int[]{};
		Burbujeo ordenarConBurbuja = new Burbujeo();
		ordenarConBurbuja.ordenar(vector);
		
		Assert.assertEquals(0, vector.length);
	}
}
